﻿
var $ = jQuery.noConflict();
function changeProvince() {
    var provinceId = $("#province").val();
    var province = $("#province option:selected").text();
    $("#hdprovince").val(province);
    $("#city").empty();
    $("<option value='0'>-请选择-</option>").appendTo($("#city"));
    $("#area").empty();
    $("<option value='0'>-请选择-</option>").appendTo($("#area"));
    if (provinceId == "0") {
        return;
    }
    var sData = "{'AddressID':'" + provinceId + "'}";
    $.get("/Handler/CommonHandler.ashx?action=GetAddresses", { AddressID: provinceId }, function (result) {
        var str = result.split("|");
        var text = "";
        for (var i = 0; i < str.length; i++) {
            var st = str[i].split(",");
            text += "<option value='" + st[0].replace("\"", "") + "'>" + st[1].replace("\"", "") + "</option>"
           
        }
        $("#city").html(text);
        changeCity();
    })

}
function changeCity() {
    var cityId = $("#city").val();
    var city = $("#city option:selected").text();
    $("#hdcity").val(city);
    $("#area").empty();
    $("<option value='0'>-请选择-</option>").appendTo($("#area"));
    if (cityId == "0") {
        return;
    }
    var sData = "{'AddressID':'" + cityId + "'}";
    $.get("/Handler/CommonHandler.ashx?action=GetAddresses", { AddressID: cityId }, function (result) {
        var str = result.split("|");
        var text = "";
        for (var i = 0; i < str.length; i++) {
            var st = str[i].split(",");
            text += "<option value='" + st[0].replace("\"", "") + "'>" + st[1].replace("\"", "") + "</option>"
            
        }
        //alert("222");
        $("#area").html(text);
        var area = $("#area option:selected").text();
        $("#hdarea").val(area);
    })

}


function changeArea()
{
    var area = $("#area option:selected").text();
    $("#hdarea").val(area);
}







//这个不要删除，这是修改用的
function changeProvince1(paraCity, paraArea) {
    var provinceId = $("#province1").val();
    var province = $("#province1 option:selected").text();
    $("#hdprovince1").val(province);
    $("#city1").empty();
    $("<option value='0'>-请选择-</option>").appendTo($("#city1"));
    $("#area1").empty();
    $("<option value='0'>-请选择-</option>").appendTo($("#area1"));
    if (provinceId == "0") {
        return;
    }
    var sData = "{'AddressID':'" + provinceId + "'}";
    $.get("/Handler/CommonHandler.ashx?action=GetAddresses", { AddressID: provinceId }, function (result) {
        var str = result.split("|");
        var text = "";
        for (var i = 0; i < str.length; i++) {
            var st = str[i].split(",");
            text += "<option value='" + st[0].replace("\"", "") + "'>" + st[1].replace("\"", "") + "</option>"

        }
        $("#city1").html(text);
        if (paraCity != "")
        {
            $("#city1 option:contains('" + paraCity + "')").attr("selected", "selected");
        }
        changeCity1(paraArea);
    })

}
function changeCity1(paraArea) {
    var cityId = $("#city1").val();
    var city = $("#city1 option:selected").text();
    $("#hdcity1").val(city);
    $("#area1").empty();
    $("<option value='0'>-请选择-</option>").appendTo($("#area1"));
    if (cityId == "0") {
        return;
    }
    var sData = "{'AddressID':'" + cityId + "'}";
    $.get("/Handler/CommonHandler.ashx?action=GetAddresses", { AddressID: cityId }, function (result) {
        var str = result.split("|");
        var text = "";
        for (var i = 0; i < str.length; i++) {
            var st = str[i].split(",");
            text += "<option value='" + st[0].replace("\"", "") + "'>" + st[1].replace("\"", "") + "</option>"

        }
        $("#area1").html(text);
        if (paraArea != "") {
            $("#area1 option:contains('" + paraArea + "')").attr("selected", "selected");
        }
        var area = $("#area1 option:selected").text();
        $("#hdarea1").val(area);
    })

}


function changeArea1() {
    var area = $("#area1 option:selected").text();
    $("#hdarea1").val(area);
}

